package com.wfh.adapter;

import java.util.ArrayList;
import java.util.List;

import com.wfh.R;
import com.wfh.share.SinaWeiBo;
import com.wfh.util.Util;

import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class PopupAdapter extends BaseAdapter {

	Context context;
	public List<String> list;
	public PopupAdapter(Context context, ArrayList<String> list) {
		this.context = context;
		this.list = list;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return list.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup arg2) {
		ViewHolder holder;
		if (convertView == null) {
			convertView = LayoutInflater.from(context).inflate(
					R.layout.adapter_popup, null);
			holder = new ViewHolder();

			convertView.setTag(holder);

			holder.groupItem = (TextView) convertView
					.findViewById(R.id.textView1);

		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		holder.groupItem.setText(list.get(position));
		switch (position) {
			case 0:
				holder.groupItem.setOnClickListener(new OnClickListener() {
					@Override
					public void onClick(View v) {
						Util.startactivity(context, SinaWeiBo.class);
					}
				});
				break;
			case 1:
				break;
			case 2:
				break;
			default:
				break;

		}
		return convertView;

	}

	static class ViewHolder {
		TextView groupItem;
	}

}
